@@ -5,6 +5,8 @@ import com.dao.UserDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.*;
        import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

//@Configuration
@@ -40,4 +42,14 @@ public class AppConfig {
        viewResolver.setSuffix(".jsp");// 自动解析后缀名
        return viewResolver;
}
@Bean
WebMvcConfigurer createWebMvcConfigurer() {
    return new WebMvcConfigurer() {
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
            registry.addResourceHandler("/static/**").
                    addResourceLocations("/static/");
        }
    };
}
}
        +16 src/main/java/com/controller/ProductController.java  100644 -> 100644
        package com.controller;

import com.pojo.Product;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@@ -23,5 +25,19 @@ for (String product : products) {
        System.out.println("获取到" + product + "的商品");
}
        }
@RequestMapping("/getProduct")
public void getProduct(@RequestBody Product product ){
    String proId = product.getProId();
    String proName = product.getProName();
    System.out.println("获取到"+proId+"名称id"+proName+"的商品");
}
@RequestMapping("/getProductList")
public void getProductList(@RequestBody List<Product> products ){
    for (Product product : products) {
        String proId = product.getProId();
        String proName = product.getProName();
        System.out.println("获取到"+proId+"名称id"+proName+"的商品");
    }
}
}